# RUN: yaml2obj %s -o %t
# Establish baseline objects for further checks. --discard-locals only discards
# compiler-generated local symbols (starting with .L), --discard-all discards
# all regular local symbols.
# RUN: llvm-objcopy %t %t-discard-none
# RUN: llvm-readobj --symbols %t-discard-none | FileCheck %s --check-prefixes=CHECK,LOCAL,COMPILER-LOCAL
# RUN: llvm-objcopy --discard-all %t %t-discard-all
# RUN: llvm-readobj --symbols %t-discard-all | FileCheck %s
# RUN: llvm-objcopy --discard-locals %t %t-discard-locals
# RUN: llvm-readobj --symbols %t-discard-locals | FileCheck %s --check-prefixes=CHECK,LOCAL

# When mixing --discard-all and --discard-locals, the last one wins.
# RUN: llvm-objcopy --discard-all --discard-locals %t %t.1.o
# RUN: cmp %t.1.o %t-discard-locals
# RUN: llvm-objcopy --discard-locals --discard-all %t %t.2.o
# RUN: cmp %t.2.o %t-discard-all
# RUN: llvm-objcopy -x -X %t %t.3.o
# RUN: cmp %t.3.o %t-discard-locals
# RUN: llvm-objcopy -X -x %t %t.4.o
# RUN: cmp %t.4.o %t-discard-all
# RUN: llvm-objcopy -x -X -x -X %t %t.5.o
# RUN: cmp %t.5.o %t-discard-locals
# RUN: llvm-objcopy -X -x -X -x %t %t.6.o
# RUN: cmp %t.6.o %t-discard-all
# RUN: llvm-objcopy -X -x -X -x --discard-locals %t %t.7.o
# RUN: cmp %t.7.o %t-discard-locals
# RUN: llvm-objcopy -X -x -X -x --discard-all %t %t.8.o
# RUN: cmp %t.8.o %t-discard-all

# llvm-strip works in the same way.
# RUN: llvm-strip --discard-all --discard-locals %t -o %t.9.o
# RUN: cmp %t.9.o %t-discard-locals
# RUN: llvm-strip --discard-locals --discard-all %t -o %t.10.o
# RUN: cmp %t.10.o %t-discard-all
# RUN: llvm-strip -x -X %t -o %t.11.o
# RUN: cmp %t.11.o %t-discard-locals
# RUN: llvm-strip -X -x %t -o %t.12.o
# RUN: cmp %t.12.o %t-discard-all
# RUN: llvm-strip -x -X -x -X %t -o %t.13.o
# RUN: cmp %t.13.o %t-discard-locals
# RUN: llvm-strip -X -x -X -x %t -o %t.14.o
# RUN: cmp %t.14.o %t-discard-all
# RUN: llvm-strip -X -x -X -x --discard-locals %t -o %t.15.o
# RUN: cmp %t.15.o %t-discard-locals
# RUN: llvm-strip -X -x -X -x --discard-all %t -o %t.16.o
# RUN: cmp %t.16.o %t-discard-all

!ELF
FileHeader:
  Class:           ELFCLASS64
  Data:            ELFDATA2LSB
  Type:            ET_REL
  Machine:         EM_X86_64
Sections:
  - Name:            .text
    Type:            SHT_PROGBITS
Symbols:
  - Name:     Local
    Type:     STT_FUNC
    Section:  .text
  - Name:     .L.str
    Type:     STT_OBJECT
    Section:  .text
  - Name:     Global
    Type:     STT_FUNC
    Section:  .text
    Binding:  STB_GLOBAL

# CHECK:               Symbols [
# CHECK-NEXT:            Symbol {
# CHECK-NEXT:              Name:
# CHECK-NEXT:              Value: 0x0
# CHECK-NEXT:              Size: 0
# CHECK-NEXT:              Binding: Local
# CHECK-NEXT:              Type: None
# CHECK-NEXT:              Other: 0
# CHECK-NEXT:              Section: Undefined
# CHECK-NEXT:            }
# LOCAL-NEXT:            Symbol {
# LOCAL-NEXT:              Name: Local
# LOCAL-NEXT:              Value:
# LOCAL-NEXT:              Size:
# LOCAL-NEXT:              Binding: Local
# LOCAL-NEXT:              Type: Function
# LOCAL-NEXT:              Other:
# LOCAL-NEXT:              Section: .text
# LOCAL-NEXT:            }
# COMPILER-LOCAL-NEXT:   Symbol {
# COMPILER-LOCAL-NEXT:     Name: .L.str
# COMPILER-LOCAL-NEXT:     Value:
# COMPILER-LOCAL-NEXT:     Size:
# COMPILER-LOCAL-NEXT:     Binding: Local
# COMPILER-LOCAL-NEXT:     Type: Object
# COMPILER-LOCAL-NEXT:     Other:
# COMPILER-LOCAL-NEXT:     Section: .text
# COMPILER-LOCAL-NEXT:   }
# CHECK-NEXT:            Symbol {
# CHECK-NEXT:              Name: Global
# CHECK-NEXT:              Value:
# CHECK-NEXT:              Size:
# CHECK-NEXT:              Binding: Global
# CHECK-NEXT:              Type: Function
# CHECK-NEXT:              Other:
# CHECK-NEXT:              Section: .text
# CHECK-NEXT:            }
# CHECK-NEXT:          ]
